Skip to content

fix: wait_for_termination returns actual exit status - #1265

Open
sweb wants to merge 5 commits into
mainfrom
fix/wait-for-term-exit-code
Open

sweb wants to merge 5 commits into
mainfrom
fix/wait-for-term-exit-code

Conversation

@sweb

@sweb sweb commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

Description

since set -e is the last part of wait_for_termination it always has exit code 0. With this, it returns the exit code of the process it is waiting for instead. [ "${term_child_pid}" ] blows up when the child pid is not set yet, so gets changed to [ -n "${term_child_pid:-}" ].

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes

Author

  • Changes are OpenShift compatible
  • CRD changes approved
  • CRD documentation for all fields, following the style guide.
  • Integration tests passed (for non trivial changes)
  • Changes need to be "offline" compatible

Reviewer

  • Code contains useful comments
  • Code contains useful logging statements
  • (Integration-)Test cases added
  • Documentation added or updated. Follows the style guide.
  • Changelog updated
  • Cargo.toml only contains references to git tags (not specific commits or branches)

Acceptance

  • Feature Tracker has been updated
  • Proper release label has been added

@sweb
sweb force-pushed the fix/wait-for-term-exit-code branch 2 times, most recently from dd6cb82 to 4e5b186 Compare August 21, 2026 12:27
@sweb sweb moved this to Development: Waiting for Review in Stackable Engineering Aug 21, 2026
@lfrancke

Copy link
Copy Markdown
Member

Ah...we just had the same/similar in stackabletech/stackable-utils#130

It's an annoying trap.

@sweb

sweb commented Aug 21, 2026

Copy link
Copy Markdown
Member Author

Ah...we just had the same/similar in stackabletech/stackable-utils#130

It's an annoying trap.

in this context, it is not a huge deal - from what I checked it does not interfere with OOM based restarts or something like that - but getting the actual exit codes may be nice and should be an improvement.

@maltesander
maltesander self-requested a review September 1, 2026 13:04
@maltesander maltesander moved this from Development: Waiting for Review to Development: In Review in Stackable Engineering Sep 1, 2026

@maltesander maltesander left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of things. Almost all downstream products require changes:

Will abort under set -e with non-zero code, neither create_vector_shutdown_file_command or other lines after that will be executed (e.g. the vector shutdown file etc.). So || product_exit_code=$? should be added and rolled out with an operator-rs release properly?

And i think a similar problem for git-sync containers


It could make sense to stop that test script duplication (i think its in over 10 places) and e.g. use insta (already in the repo) as dev/test dependency? Something like:

insta::assert_snapshot!(
    serde_yaml::to_string(&git_sync_resources.git_sync_containers.first()).unwrap()
);

Comment thread crates/stackable-operator/src/crd/git_sync/v1alpha1_impl.rs Outdated
@sweb
sweb force-pushed the fix/wait-for-term-exit-code branch from f3a4fee to 64793f9 Compare September 25, 2026 08:53
@sweb

sweb commented Sep 25, 2026 •

Copy link
Copy Markdown
Member Author

@maltesander sorry for the long time it took me to work through your comments properly. I have now extended the changelog (126afa0) to mark this as breaking and added additional tests for checking if commands after product crash + wait_for_termination are executed and how sigterm before there is a child PID is handled (e973e6b).

Next, I am looking at insta.

@sweb
sweb force-pushed the fix/wait-for-term-exit-code branch from 64793f9 to e973e6b Compare September 25, 2026 09:01
@sweb
sweb force-pushed the fix/wait-for-term-exit-code branch from f36e2e0 to d8849ca Compare September 25, 2026 10:42
@sweb

sweb commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

@maltesander I changed the tests to use insta - see 704b60a

It simplifies a bunch of things (some clippy lints can go away) but on the other hand we have additional files. Take a look whether you like it, otherwise I can also drop this commit.

@sweb
sweb requested a review from maltesander September 25, 2026 11:48

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development: In Review

Development

Successfully merging this pull request may close these issues.

3 participants